package com.lc.common.execption;

import com.lc.common.result.ResultCodeEnum;
import lombok.Data;

@Data
public class LcException extends RuntimeException{
    private Integer code;

    private String message;

    /**
     * 通过状态码和错误消息创建异常对象
     * @param code  状态码
     * @param message   异常信息
     */
    public LcException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    /**
     * 接收枚举类型对象
     * @param resultCodeEnum    返回状态码
     */
    public LcException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
        this.message = resultCodeEnum.getMessage();
    }


    @Override
    public String toString() {
        return "LcException{" +
                "code=" + code +
                ", message=" + this.getMessage() +
                '}';
    }

}
